export const uuid = () => {
  /*jshint bitwise:false */
  let i, random;
  let uuid = '';

  for (i = 0; i < 32; i++) {
    random = Math.random() * 16 | 0;
    if (i === 8 || i === 12 || i === 16 || i === 20) {
      uuid += '-';
    }
    uuid += (i === 12 ? 4 : (i === 16 ? (random & 3 | 8) : random))
      .toString(16);
  }

  return uuid;
}

/*级联菜单优化 */
export const searchOption = (sortTree) => {
  if (sortTree.length == 0) return []
  sortTree.map(item => {
    if (item.childList&&item.childList.length > 0) {
      item.childList.map(ele => {
        if (ele.childList&&ele.childList.length > 0) {
          ele.childList.map(value => {
            if (value.childList&&value.childList.length > 0) {
              value.childList = null
            }else{
              value.childList = null
            }
          })
        }else{
          ele.childList = null
        }
      })
    }else {
      item.childList = null
    }
  })
  return sortTree
}
